<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tlds/struts-tags.tld" prefix="s"%>
<%@taglib uri="/WEB-INF/tlds/c.tld" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib prefix="sx" uri="/struts-dojo-tags"%>

<fieldset class="fieldsetMenu">
	<legend>
		<s:text name="MonAffichage.label.resume"></s:text>
	</legend>
	<b><s:text name="MonAffichage.titre.filtre"></s:text></b>
	<form id="filtrerdemandesForm" action="filtrerdemandesForm">
		<div class="form-horizontal pull-left cssDivFormMonAffichage">

			<div class="control-group">
				<label class="control-label"><s:text
						name="MonAffichage.utilisateur"></s:text></label>
				<div class="groups">
					<s:if test="%{personne != null && etat != 'personne'}">
						<s:select cssClass="select2" list="listeUtilisateurs"
							name="personne"></s:select>
					</s:if>
					<s:else>
						<s:select cssClass="select2" list="listeUtilisateurs"
							value="%{personne}" name="personne"></s:select>
					</s:else>
				</div>
			</div>

			<s:fielderror cssClass="erreurDate" fieldName="DateError1" />
			<div class="control-group">
				<label class="control-label"><s:text
						name="MonAffichage.label.date1"></s:text></label>
				<div class="groups">
					<s:if test="%{date1 != null && date1 != ''}">
						<s:textfield cssClass="datepickerinput" name="date1"></s:textfield>
					</s:if>
					<s:else>
						<s:textfield cssClass="datepickerinput" name="date1"
							value="%{date1}"></s:textfield>
					</s:else>
				</div>
			</div>

		</div>

		<div class="form-horizontal pull-left cssDivFormMonAffichage">
			<div class="control-group">
				<label class="control-label"><s:text
						name="MonAffichage.etat"></s:text></label>
				<div class="groups">
					<s:if test="%{etat != null && etat != ''}">
						<s:select cssClass="select2" list="listeEtats" name="etat"
							value="%{etat}"></s:select>
					</s:if>
					<s:else>
						<s:select cssClass="select2" list="listeEtats" name="etat"
							value="%{'Ouverte'}"></s:select>
					</s:else>
				</div>
			</div>

			<s:fielderror cssClass="erreurDate" fieldName="DateError2" />
			<div class="control-group">
				<label class="control-label"><s:text
						name="MonAffichage.label.date2"></s:text></label>
				<div class="groups">
					<s:if test="%{date2 != null && date2 != ''}">
						<s:textfield cssClass="datepickerinput" name="date2"></s:textfield>
					</s:if>
					<s:else>
						<s:textfield cssClass="datepickerinput" name="date2"
							value="%{date2}"></s:textfield>
					</s:else>
				</div>
			</div>
		</div>

		<div class="form-horizontal pull-left cssDivFormMonAffichage">

			<div class="control-group">
				<label class="control-label"><s:text
						name="MonAffichage.typeDemande"></s:text></label>
				<div class="groups">
					<s:if test="%{type != null && type != ''}">
						<s:select cssClass="select2" list="listeTypeDemandes" name="type"></s:select>
					</s:if>
					<s:else>
						<s:select cssClass="select2" list="listeTypeDemandes" name="type"
							value="%{type}"></s:select>
					</s:else>
				</div>
			</div>

			<div class="control-group">
				<label class="control-label"></label>
				<div class="groups">
					<button type="submit" class="btn">
						<s:text name="MonAffichage.label.submit"></s:text>
					</button>
				</div>
			</div>

		</div>

		<div class="clearfix"></div>

	</form>

	<b><s:text name="MonAffichage.titre.rechercher"></s:text></b>
	<s:form method="post" id="recherchedemandesForm"
		action="recherchedemandesForm">
		<div class="form-horizontal cssDivFormRecherchedemandesForm">
			<div class="control-group">
				<label class="control-label"><s:text
						name="MonAffichage.label.rechercher"></s:text></label>
				<div class="groups">
					<s:textfield id="nomdemandeauto" name="nomcp" value="" />
					<button type="submit" class="btn">
						<s:text name="MonAffichage.bouton.rechercher"></s:text>
					</button>
				</div>
			</div>
		</div>
	</s:form>

	<form action="traitementDemande" name="monAff">
		<div class="row-fluid">
			<table id="tableau" class="tableCompteRendu">
				<thead>
					<tr>
						<th><s:text name="MonAffichage.label.nom"></s:text></th>
						<th><s:text name="MonAffichage.label.type.demande"></s:text></th>
						<th><s:text name="MonAffichage.label.etat"></s:text></th>
						<th><s:text name="MonAffichage.label.date.emission"></s:text></th>
						<th><s:text name="MonAffichage.label.date.dernier.etat"></s:text></th>
						<th><s:text name="MonAffichage.label.environnement"></s:text></th>
						<th><s:text name="MonAffichage.label.consulter"></s:text></th>
						<th><s:text name="MonAffichage.label.annuler"></s:text></th>
						<th><s:text name="MonAffichage.label.modifier"></s:text></th>
						<th><s:text name="MonAffichage.label.supprimer"></s:text></th>

					</tr>
				</thead>
				<tbody>
					<s:if test="listeDemandes.size !=0">
						<s:iterator value="listeDemandes" var="demande" status="rowStatus">
							<tr
								<s:if test="#rowStatus.odd == false	"> class="lignePaire" </s:if>>
								<%--attributs demandes --%>
								<td><s:property value="#demande.titreCPDemande" /></td>
								<td><s:property
										value="#demande.CDDemandeCPDemande.typeDemandeCDDemande.nomTypeDemande" /></td>
								<td><s:property value="#demande.etatCPDemande.nomEtat" /></td>
								<td><s:date name="#demande.dateCPDemande"
										format="HH:mm:ss dd/MM/yyyy" /></td>
								<td><s:date name="#demande.dateEtat"
										format="HH:mm:ss dd/MM/yyyy" /></td>

								<td>
								 <s:iterator
										value="#demande.getParametreDemandeCPDemandes()" var="params">
										<s:if
											test="%{#params.getCDParametresDemandeCPParametreDemande().getNomParametreDemande().equalsIgnoreCase('environnement')}">
											<s:property value="#params.getValeurCPParametreDemande()" />
										</s:if>
									</s:iterator> 
								</td>
									
								<input type="hidden" name="idDemand" id="idDemand" />

								<s:if
									test="%{#demande.etatCPDemande.nomEtat=='En cours de traitement'}">

									<%--consulter --%>
									<td><s:url action="consultationdemande"
											var="urlConsultationDemande">
											<s:param name="idDemande">
												<s:property value="#demande.identifiantCPDemande" />
											</s:param>
										</s:url> <a href="<s:property value="#urlConsultationDemande" />"><img
											src="<s:url value='/media/images/search15.png'/>"
											width="15px" height="15px" /></a>
									</td>
									<td></td>
									<td></td>
									<td></td>

								</s:if>

								<s:elseif test="%{#demande.etatCPDemande.nomEtat=='En attente'}">

									<%--consulter --%>
									<td><s:url action="consultationdemande"
											var="urlConsultationDemande">
											<s:param name="idDemande">
												<s:property value="#demande.identifiantCPDemande" />
											</s:param>
										</s:url> <a href="<s:property value="#urlConsultationDemande" />"><img
											src="<s:url value='/media/images/search15.png'/>"
											width="15px" height="15px" /></a></td>
									<%--annuler --%>
									<td><input value="submit"
										src='<s:url value="/media/images/croix15.png"/>' width="15px"
										height="15px" type=image action="traitementDemande"
										name="annuler[<s:property value="#demande.identifiantCPDemande"/>]"
										method="traitementDemande()"
										onClick="javascript: if (confirm('Voulez vous vraiment annuler la demande: <s:property value="#demande.identifiantCPDemande"/>')) return true; else return false;" /></td>
									<td></td>
									<td></td>
								</s:elseif>
								<s:elseif test="%{#demande.etatCPDemande.nomEtat=='Ouverte'}">
							
									<%--consulter --%>
									<td><s:url action="consultationdemande"
											var="urlConsultationDemande">
											<s:param name="idDemande">
												<s:property value="#demande.identifiantCPDemande" />
											</s:param>
										</s:url> <a href="<s:property value="#urlConsultationDemande" />"><img
											src="<s:url value='/media/images/search25.png'/>"
											width="15px" height="15px" /></a>
									</td>
											<td><input value="submit"
										src='<s:url value="/media/images/croix15.png"/>' width="15px"
										height="15px" type=image action="traitementDemande"
										name="annuler[<s:property value="#demande.identifiantCPDemande"/>]"
										method="traitementDemande()"
										onClick="javascript: if (confirm('Voulez vous vraiment annuler la demande: <s:property value="#demande.identifiantCPDemande"/>')) return true; else return false;" /></td>
									</td>
									
									<td>
										<s:url action="modifierdemande"
										var="urlModifierDemande">
										<s:param name="idDemande">
											<s:property value="#demande.identifiantCPDemande" />
										</s:param>
									</s:url> <a href="<s:property value="#urlModifierDemande" />"><img
										src="<s:url value='/media/images/txt15.png'/>" width="15px"
										height="15px" /></a>
									</td>
											
											<td></td>
								</s:elseif>
								<s:elseif test="%{#demande.etatCPDemande.nomEtat=='Invalidée'}">

									<%--consulter --%>
									<td><s:url action="consultationdemande"
											var="urlConsultationDemande">
											<s:param name="idDemande">
												<s:property value="#demande.identifiantCPDemande" />
											</s:param>
										</s:url> <a href="<s:property value="#urlConsultationDemande" />"><img
											src="<s:url value='/media/images/search15.png'/>"
											width="15px" height="15px" /></a>
									</td>
									<td>
										<input value="submit"
											src='<s:url value="/media/images/croix15.png"/>' width="15px"
											height="15px" type=image action="traitementDemande"
											name="annuler[<s:property value="#demande.identifiantCPDemande"/>]"
											method="traitementDemande()"
											onClick="javascript: if (confirm('Voulez vous vraiment annuler la demande: <s:property value="#demande.identifiantCPDemande"/>')) return true; else return false;" />
									</td>
									<td><s:url action="modifierdemande"
											var="urlModifierDemande">
											<s:param name="idDemande">
												<s:property value="#demande.identifiantCPDemande" />
											</s:param>
										</s:url> <a href="<s:property value="#urlModifierDemande" />"><img
											src="<s:url value='/media/images/txt15.png'/>" width="15px"
											height="15px" /></a>
									</td>
									<td></td>


								</s:elseif>
								<s:elseif
									test="%{#demande.etatCPDemande.nomEtat=='Annulée'| #demande.etatCPDemande.nomEtat=='Close'}">

									<%--consulter --%>
									<td><s:url action="consultationdemande"
											var="urlConsultationDemande">
											<s:param name="idDemande">
												<s:property value="#demande.identifiantCPDemande" />
											</s:param>
										</s:url> <a href="<s:property value="#urlConsultationDemande" />"><img
											src="<s:url value='/media/images/search15.png'/>"
											width="15px" height="15px" /></a></td>
									<td></td>
									<td></td>
									<td><input value="submit"
										src='<s:url value="/media/images/corbeille.png"/>'
										width="15px" height="15px" type=image
										action="traitementDemande"
										name="supprimer[<s:property value="#demande.identifiantCPDemande"/>]"
										method="traitementDemande()"
										onClick="javascript: if (confirm('Voulez vous vraiment supprimer la demande: <s:property value="#demande.identifiantCPDemande"/>')) return true; else return false;" /></td>
								</s:elseif>
								<s:elseif test="%{#demande.etatCPDemande.nomEtat=='Ré-ouverte'}">

									<%--consulter --%>
									<td><s:url action="consultationdemande"
											var="urlConsultationDemande">
											<s:param name="idDemande">
												<s:property value="#demande.identifiantCPDemande" />
											</s:param>
										</s:url> <a href="<s:property value="#urlConsultationDemande" />"><img
											src="<s:url value='/media/images/search15.png'/>"
											width="15px" height="15px" /></a></td>
									<%--annuler --%>
									<td><input value="submit"
										src='<s:url value="/media/images/croix15.png"/>' width="15px"
										height="15px" type=image action="traitementDemande"
										name="annuler[<s:property value="#demande.identifiantCPDemande"/>]"
										method="traitementDemande()"
										onClick="javascript: if (confirm('Voulez vous vraiment annuler la demande: <s:property value="#demande.identifiantCPDemande"/>')) return true; else return false;" /></td>
									<td></td>
									<td></td>
								</s:elseif>
								<s:else>
									<td></td>
									<td></td>
									<td></td>
									<td></td>
								</s:else>
						</s:iterator>
					</s:if>
					<s:else>
						<tr>
							<td colspan="11"><s:text name="Label.aucun.resultat"></s:text></td>
						</tr>
					</s:else>

				</tbody>
			</table>
			<s:div id="nombreLignes">
				<%-- <s:select listValue="" ></s:select> --%>
			</s:div>
		</div>
	</form>
</fieldset>

<content tag="javascriptPage">
 <script
	src="<s:url value='/media/js/TableSorter/jquery.tablesorter.js'/>"
	type="text/javascript"></script> <script
	src="<s:url value='/js/appli/monaffichage.js'/>" type="text/javascript"></script>
</content>

<span class="hidden" id="url_img_datepicker"><s:url
		value="/media/images/calendar.png"></s:url></span>